The bucket was
filled with water and placed outside. The outside air temperature is t degrees.
Print “Water” if t is positive, and “Ice” otherwise.
Input. One integer t
(-109 ≤ t ≤ -109).
Output. Print “Water” if t
is positive, and “Ice” if t is zero or
negative.
Sample input 1 |
Sample output 1 |
3 |
Water |
|
|
Sample input 2 |
Sample output 2 |
-6 |
Ice |
conditional
statement
To solve
this problem, use a conditional statement.
Algorithm
implementation
Read the input temperature value t.
scanf("%d", &t);
Based on the value of t, print the corresponding result.
if (t > 0)
printf("Water\n");
else
printf("Ice\n");
Java implementation
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
int t = con.nextInt();
if (t > 0)
System.out.println("Water");
else
System.out.println("Ice");
con.close();
}
}
Python implementation
Read the input temperature value t.
t = int(input())
Based on the value of t, print the corresponding result.
if t > 0:
print("Water")
else:
print("Ice")